home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / bbs / fax_it_cnet.lzh / FAX-IT / fax-it < prev    next >
Text File  |  1994-09-10  |  11KB  |  438 lines

  1. /*
  2. **   FAX-IT! V3.0    By: Glenn J. Schworak  ((CNet Version))
  3. **
  4. **      ******************************************************
  5. **      * This program should not be altered for any reason. *
  6. **      * Any changes may cause the program to fail          *
  7. **      ******************************************************
  8. **
  9. **    This is a door program to allow messages to be written on any
  10. **    Excelsior! BBS system. The system must also have GPFax running
  11. **    when the FAX messages are sent out using AutoFAX.
  12. **
  13. **  If you modify these scripts to run on any BBS other than Excelsior!
  14. **  you MUST re-archive all the files and return it to me. You are allowed
  15. **  to take credit for any of the modifications you make but DO NOT start
  16. **  to distribute your work until I get a copy please.
  17. **
  18. **    This program was written by Glenn J. Schworak February, 1994
  19. **
  20. **    FAX-IT is Copyright ©1994 by Boundless Systems & Software
  21. **                                 1710 Lee Street SE
  22. **                                 Salem, Oregon 97302
  23. **                                 (503) 399-7518 - Voice Line
  24. **                                 (503) 581-6524 - FAX/BBS Line
  25. */
  26.  
  27. Options Results
  28.  
  29. GetUser 27 ;  TrueWidth   =  Result
  30. GetUser  3 ;  TrueName    =  Result
  31. GetUser  1 ;  TrueAlias   =  Result
  32. GetUser  4 ;  TrueLocal   =  Result
  33. GetUser  5 ;  TrueLocal   =  TrueLocal' 'Result
  34. GetUser 56 ;  TrueLocal   =  TrueLocal' ('Result')'
  35. GetUser  6 ;  TrueAddress =  Result
  36. GetUser  9 ;  TrueNumber  =  Result
  37. GetUser 40 ;  TrueID      =  Result
  38. GetUser 23 ;  Portx      =  Result
  39. GetUser 2307386 ; WorkPath = Result
  40.  
  41.  
  42. Doors = 'Doors:'
  43. FaxIT         = Doors'Fax-IT/'
  44. Config    = FaxIT'Fax-It.cfg'
  45. Times         = FaxIT'FAX-Times'
  46. Numbers    = FaxIT'Numbers/'
  47. NumFile   = FAXIT'NumberList.'TrueID
  48.  
  49. Spawn FaxIT'FAX-Stat'
  50.  
  51. bufferflush
  52.  
  53. Signal On IOerr
  54. Signal On syntax
  55.  
  56. ChangeWhere 'FAX-IT!'
  57. ChangeWhat  'Initializing'
  58.  
  59. Yes = 'YES'
  60. No  = 'NO'
  61.  
  62. SendFile Doors'Fax-IT/FAX-IT.Welcome'
  63. Print 'c4k1FAX-IT v3.0k0 c5by c2Glenn J. Schworakc5 for k1 EXCELSIOR! BBSk0c5 andk1 GPFaxk0c5 software!q1n1'
  64. Print 'cbCNet Modification by Malcolm Anderson. n1cfCall The AfterHOurs Cafe BBS (209) 464-0219n1'
  65. Print 'c1Please DO NOT use MCI commands in this message. FAX machines do not understand them so they will be printed just as you enter them.n1'
  66. Print 'k1r1Note:q1 c4Your real name, phone number, and address are attached to'
  67. Print 'c4      each FAX you send out.n2'
  68.  
  69.  
  70. /*
  71.  * Reading the config file
  72.  */
  73.  
  74. settings=0
  75. if open(cfg,config,'read') then do
  76.     do while ~eof(cfg)
  77.         text=upper(readln(cfg))
  78.         if left(text,1)~=';' | length(text)<4 then do
  79.             if text='FORCEFAX' then do
  80.                 ForceFAX=trim(upper(ReadLN(cfg)))
  81.                 Settings=Settings+1
  82.             end
  83.             if text='LOCALONLY' then do
  84.                 LocalOnly=trim(upper(ReadLN(cfg)))
  85.                 settings=settings+1
  86.             end
  87.             if text='LOCALPREFIX' then do
  88.                 LocalPrefix=Trim(readln(cfg))
  89.                 settings=settings+1
  90.             end
  91.             if text='ALLOWLONG' then do
  92.                 AllowLong=Trim(readln(cfg))
  93.                 settings=settings+1
  94.             end
  95.             if text='TIMEMSG' then do
  96.                 TimeMSG=trim(readln(cfg))
  97.                 settings=settings+1
  98.             end
  99.             if text='SAREA' then do
  100.                 SArea=trim(readln(cfg))
  101.                 settings=settings+1
  102.             end
  103.             if text='SPICT' then do
  104.                 SPict=trim(readln(cfg))
  105.                 settings=settings+1
  106.                 if SPict='*' | length(SPict)=0 then SPict=""; else Spict='G'SPict
  107.             end
  108.             if text='SNAME' then do
  109.                 SName=trim(Readln(cfg))
  110.                 settings=settings+1
  111.             end
  112.             if text='SNUM' then do
  113.                 SNum=trim(readln(cfg))
  114.                 settings=settings+1
  115.             end
  116.             if text='SLOCAL' then do
  117.                 SLocal=trim(readln(cfg))
  118.                 settings=settings+1
  119.             end
  120.             if text='SMESSAGE' then do
  121.                 SMessage=trim(readln(cfg))
  122.                 settings=settings+1
  123.             end
  124.         end
  125.     end
  126.     close(cfg)
  127. end            
  128. if settings>11 then do
  129.     Print 'There are too many entries in the config file. FAX abortedn2'
  130.     call quit
  131. end
  132. if settings<11 then do
  133.     Print 'There are not enough entries in the config file. FAX abortedn2'
  134.     call quit
  135. end
  136.             
  137.  
  138. /*
  139.  * Check for sysop or user access group that will over ride the
  140.  * local only setting. Sysop can send to any number and so can a user
  141.  * with an access group found in the variable AllowLong listed above.
  142.  */
  143.  
  144. GetUser 17 ;  If Result = 1 Then LocalOnly = NO 
  145. GetUser 15 ;  If index(AllowLong,'-'Result'-')>0 then LocalOnly = NO
  146.                                    
  147.  
  148. /*
  149.  *   Main Program - Please DO NOT make any changes below this point.
  150.  */
  151.  
  152. stat=Exists(Times)
  153. if stat~=1 then do
  154.     Print 'b1c1ERROR: c6The c3FAX-Times c6file is missing from the FAX-IT door area...w4q1'
  155.     Call Quit
  156. end
  157. Open(tempfile,Times,'read') 
  158.     hours=readln(tempfile)
  159.     days=readln(tempfile)    
  160. Close(tempfile)
  161.  
  162. Now = '-'Time('Hours')'-'
  163. Day = SubStr(Date('W'),1,3)
  164.  
  165. TrueTime = Time('C')'  'Date('Normal')
  166. FileTime = 'GJSFAX'Compress(Date(Sorted)'.'Time(),':')
  167.  
  168. If Index(Hours,Now)=0 | Index(Days,Day)=0 Then SendNow=No; else SendNow=Yes
  169.  
  170. address command 'list >'NumFile' "'Numbers'~(1 #?)" LFormat "%s"'
  171. if LocalOnly=No then address command 'list >>'NumFile' "'Numbers'1 #?" LFormat "%s"'
  172. Print TimeMSG
  173. TempNum='***'
  174. do while TempNum='***'
  175.     Print 'n2c6(Type c7HELPc6 for more information or c7LISTc6 for phone numbers)'
  176.     Query 'q1Enter the phone number or company name to send your FAX to? c2'
  177.  
  178.     TempNum = Result
  179.  
  180.     if TempNum='' then do
  181.         print 'c1NO FAX SENTq1n2'
  182.         Call Quit
  183.     end
  184.     if Upper(TempNum)='HELP' then do
  185.       print 'f1b1'
  186.       SendFile Doors'Fax-IT/Help.FAX'
  187.       TempNum='***'
  188.     end
  189.     if Upper(TempNum)='LIST' then do
  190.       Print 'f1b1q1To add your number to the list contact the Sysopn2c2List of FAX numbers known to this system...n2'
  191.       lines=6
  192.       if open(FileList,NumFile,'Read') then do
  193.         do while ~eof(FileList) & lines>=0
  194.             filename=readln(FileList)
  195.             if open(NumberFile,Numbers||filename,'Read') then do
  196.                 print 'n1c6'filename'q1'
  197.                 lines=lines+2
  198.                 do while ~eof(NumberFile)
  199.                     text=readln(NumberFile)
  200.                     if length(text)>1 then do
  201.                         print text
  202.                         lines=lines+1
  203.                     end
  204.                 end
  205.                 close(NumberFile)
  206.                 if lines>20 then do
  207.                     lines=0
  208.                     Query 'n1q1More (c2Yq1/n) '
  209.                     if result='n' then lines=-5
  210.                 end
  211.                 
  212.             end
  213.         end
  214.         close(FileList)
  215.       end
  216.       TempNum='***'
  217.       print 'n2k1  --- END OF LIST --- k0q1'
  218.     end
  219.  
  220.     TempText=Upper(TempNum)
  221.     lines=0
  222.     if open(FileList,NumFile,'Read') then do
  223.            do while ~eof(FileList) & lines>=0
  224.             filename=readln(FileList)
  225.             if open(NumberFile,Numbers||filename,'Read') then do
  226.                 text=left(readln(NumberFile),length(TempText))
  227.                 if Upper(text)=TempText then do
  228.                     TempNum=FileName
  229.                     lines=-1
  230.                 end
  231.                 close(NumberFile)
  232.             end
  233.         end
  234.         close(FileList)
  235.     end
  236.     
  237.  
  238.     RealNum = ""
  239.     TempNum = Compress(TempNum)
  240.     Size=WordLength(TempNum,1)
  241.     Z=1
  242.     If SubStr(TempNum,1,1)='1' Then Z=2
  243.  
  244.     Do X=Z to Size
  245.       If DataType(SubStr(TempNum,X,1),'Numeric') Then RealNum=RealNum||SubStr(TempNum,X,1)
  246.     End
  247.  
  248.     Size = WordLength(RealNum,1,1)
  249.     PreFix=SubStr(RealNum,1,3)
  250.     LongDist=Yes
  251.     If Index(LocalPrefix,Prefix)>0 then LongDist=No
  252.  
  253.     If LocalOnly=Yes & (Size>7 | LongDist=Yes) Then do
  254.       RealNum=''
  255.       Size=0
  256.       Print 'c1Sorry, your access is not high enough to send'
  257.       print 'a FAX to a long distance phone numbers.'
  258.       TempNum='***'
  259.     end
  260.  
  261.     If SubStr(RealNum,1,3)=SArea then do
  262.       Size=Size-3
  263.       RealNum=SubStr(RealNum,4,Size)
  264.     End
  265.  
  266.     If Size~=7 & Size~=10 Then do
  267.       if TempNum~='***' then do
  268.           Print 'c1This seems to be an invalid number...n1q1Please re-enter your number or leave the number blank to exit.'
  269.           TempNum='***'
  270.       end
  271.     End
  272. end
  273.  
  274. If Size=7 Then do
  275.   RealNum=Insert('-',RealNum,3)
  276. end
  277.  
  278. If Size=10 Then do
  279.   RealNum=Insert('-',RealNum,6)
  280.   RealNum=Insert(') ',RealNum,3)
  281.   RealNum=Insert('(',RealNum)
  282. End
  283.  
  284. Dial=RealNum
  285. If LongDist=Yes then Dial='1 'RealNum
  286.  
  287. print 'n2q1Send FAX to: c7'Dial
  288. if exists(Numbers||Dial) then do
  289.     if open(message,Numbers||Dial,'Read') then do
  290.         do while ~eof(message)
  291.             print readln(message)
  292.         end
  293.         close(message)
  294.     end
  295. end
  296.  
  297. Query 'n1q1Who is this FAX to be addressed to? c2'
  298. Attention = Result
  299. if Attention = '' Then Attention = 'Whom It May Concern'
  300.  
  301. Prompt 30 NORMAL 'q1Subject: c2'
  302. Subject = Result
  303. if Subject = '' Then Subject = '<None>'
  304.  
  305. ChangeWhat 'Verifying'
  306. Print 'n3q1Send c6'Attention'q1 a FAX at c6'RealNum
  307. Prompt 1 YESNO '"n1q1b1Is this information correct? (c2Yq1/n) "'
  308.  
  309. Continue=Result
  310. If Continue~='Yes' then do
  311.     Print 'n3c1*** FAX TERMINATED BY USER ***q1n2'
  312.     Call Quit
  313. end
  314.  
  315. Shell Command 'Delete <>NIL: 'workpath'_edbuff'portx
  316.  
  317. if TrueWidth>65 Then SetWidth 65
  318.  
  319. ClearEditor
  320. ChangeWhat 'Entering Message'
  321. SetWidth TrueWidth
  322. CallEditor
  323.  
  324. if ~exists(workpath'_edbuff'Portx) then do
  325.     Print 'n2c1*** NO FAX WILL BE SENT ***q1n2'
  326.     Call Quit
  327.  
  328.  
  329. end
  330.  
  331. TempFile = 'T:'FileTime
  332. RealFile = Doors'Fax-IT/Text/'FileTime
  333.  
  334. SaveEditor TempFile
  335.  
  336. File=Open('OutFile',RealFile,'Write')
  337.  
  338. If File~=1 Then do
  339.   Print 'n2c1b9ERROR CREATING FAX PRIMER FILE --- NO FAX WILL BE SENTq1n2'
  340.   Call Quit
  341. end
  342.  
  343.  
  344. WriteLN('OutFile',Dial)
  345. WriteLN('OutFile',SPict)
  346. WriteLN('OutFile','')
  347. WriteLN('OutFile','This Message is coming to you by way of....')
  348. WriteLN('OutFile','          'SName)
  349. WriteLN('OutFile','          'SLocal)
  350. WriteLN('OutFile','          'SNum)
  351. WriteLN('OutFile','          'SMessage)
  352. WriteLN('OutFile','')
  353. WriteLN('OutFile','')
  354. WriteLN('OutFile','')
  355. WriteLN('OutFile','')
  356. WriteLN('OutFile','     TO: 'Attention)
  357. WriteLN('OutFile','    FAX: 'RealNum)
  358. WriteLN('OutFile','SUBJECT: 'Subject)
  359. WriteLN('OutFile','')
  360. WriteLN('OutFile','')
  361. WriteLN('OutFile','')
  362. WriteLN('OutFile','   FROM: 'TrueName'  #'TrueID)
  363. WriteLN('OutFile','  VOICE: 'TrueNumber)
  364. WriteLN('OutFile','   ADDR: 'TrueAddress)
  365. WriteLN('OutFile','         'TrueLocal)
  366. WriteLN('OutFile','')
  367. WriteLN('OutFile','WRITTEN: 'TrueTime)
  368. WriteLN('OutFile','P')
  369.  
  370. File = Open('InFile',TempFile,'Read')
  371. if File~=1 then do
  372.     Print 'c1n2b5ERROR COMPLETING FAX PRIMER FILE --- FAX MAY BE DAMAGEDq1n2'
  373.     Close('OutFile')
  374.     Call Quit
  375. end
  376.  
  377. do while ~EOF('InFile')
  378.     TempLine = ReadLN('InFile')
  379.     WriteLN('OutFile',TempLine)
  380. end
  381.  
  382. Close('OutFile')
  383. Close('InFile')
  384.  
  385. SysopLog 'n1b1c6FAX-IT message written by 'TrueAlias' 'TrueTime' to 'RealNum'q1n1'
  386.  
  387. if ~Show(port,REXX_GPFAX) then do
  388.     Print 'n2c6Your FAX can not be sent at this time.n2'
  389.     Print 'q1The FAX is now in the holding area and will be sent at the next'
  390.     Print 'available FAX time.n2'
  391.     Call Quit
  392. end
  393.  
  394. Try=Exists('T:FAXnode')
  395. Address Command 'Delete T:GJSFAX#?'
  396. if ForceFAX=Yes & SendNow=No then do
  397.     Print 'n2c6It is now 'time('civil')' on a 'date(w)'.n2'
  398.     Query 'q1This is outside of the normal FAXing times. Try anyway? (y/c1Nq1) '
  399.     if Result="y" then do
  400.        Call Force
  401.         SendNow=Yes
  402.        end 
  403.     else do
  404.        Print 'Your message will be sent at the next available FAX time.n2'
  405.     end
  406. end
  407.  
  408. if Try='1' & SendNow=Yes then do
  409.     Call Force
  410.       Print 'The FAX line is in use at the momentn2Your FAX will be sent as soon as the line is free.n2'
  411.     Call Quit
  412. end
  413.  
  414. if SendNow=Yes then do
  415.     Print 'The FAX line is free at the moment so your fax is now being sent.n2'
  416.     address command 'C:Run >NIL: SYS:RexxC/RX 'Doors'Fax-IT/AutoFAX.gpf'
  417.     Call Quit
  418. end
  419.  
  420. Print 'Your message will be sent at the next available FAX time.n2'
  421. Call Quit
  422.  
  423. Syntax:    Print 'Syntax Error Hit!   Tell the sysop...'
  424.         Call Quit
  425.         
  426. IOerr:  Print 'I/O Error Hit!   Tell the sysop...'
  427.         Call Quit
  428.  
  429. Force:
  430.     Open(tempfile,'T:FAX-NOW','write')
  431.     writeln(tempfile,FileTime)
  432.     Close(tempfile)
  433.     return
  434.  
  435. Quit:
  436.     address command 'Delete 'NumFile
  437.     exit
  438.